/*
 * SLIRP: The (Sl)ang (I)nte(r)face (P)ackage is a code generator,
 * like S.W.I.G. for S-Lang.
 *
 * Copyright (C) 2003 Massachusetts Institute of Technology 
 * Copyright (C) 2002 Michael S. Noble <mnoble@space.mit.edu>
 *
 * This software was partially developed by the MIT Center for Space
 * Research under contract SV1-61010 from the Smithsonian Institution.
 * 
 * Permission to use, copy, modify, distribute, and sell this software
 * and its documentation for any purpose is hereby granted without fee,
 * provided that the above copyright notice appear in all copies and
 * that both that copyright notice and this permission notice appear in
 * the supporting documentation, and that the name of the Massachusetts
 * Institute of Technology not be used in advertising or publicity
 * pertaining to distribution of the software without specific, written
 * prior permission.  The Massachusetts Institute of Technology makes
 * no representations about the suitability of this software for any
 * purpose.  It is provided "as is" without express or implied warranty.
 * 
 * THE MASSACHUSETTS INSTITUTE OF TECHNOLOGY DISCLAIMS ALL WARRANTIES
 * WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS.  IN NO EVENT SHALL THE MASSACHUSETTS
 * INSTITUTE OF TECHNOLOGY BE LIABLE FOR ANY SPECIAL, INDIRECT OR
 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
 * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
 * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
 * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 */

/* This file contains a series of macros which regularize the treatment   */
/* of the various S-Lang types, and simplify intrinsic func table entries */

#define GTKOPAQUE_PLACEHOLDER 255

#define SLANG_COMPLEX_TYPE_push(r,i)	  SLang_push_complex(r,i)
#define SLANG_CHAR_TYPE_push(src,aux)	  SLang_push_char(src)
#define SLANG_UCHAR_TYPE_push(src,aux)	  SLang_push_uchar(src)
#define SLANG_INT_TYPE_push(src,aux)	  SLang_push_integer(src)
#define SLANG_UINT_TYPE_push(src,aux)	  SLang_push_uinteger(src)
#define SLANG_SHORT_TYPE_push(src,aux)	  SLang_push_short(src)
#define SLANG_USHORT_TYPE_push(src,aux)	  SLang_push_ushort(src)
#define SLANG_LONG_TYPE_push(src,aux)	  SLang_push_long(src)
#define SLANG_ULONG_TYPE_push(src,aux)	  SLang_push_ulong(src)
#define SLANG_FLOAT_TYPE_push(src,aux)	  SLang_push_float(src)
#define SLANG_DOUBLE_TYPE_push(src,aux)	  SLang_push_double(src)
#define SLANG_STRING_TYPE_push(src,aux)	  SLang_push_string(src)
#define SLANG_OPAQUE_TYPE_push(src,type)  SLang_push_opaque(type,src,0)
#define SLANG_STRUCT_TYPE_push(s,layout)  SLang_push_cstruct(s,layout)

#define SLANG_CHAR_TYPE_pop(dest,aux)	  SLang_pop_char(dest)
#define SLANG_UCHAR_TYPE_pop(dest,aux)	  SLang_pop_uchar(dest)
#define SLANG_INT_TYPE_pop(dest,aux)	  SLang_pop_integer(dest)
#define SLANG_UINT_TYPE_pop(dest,aux)	  SLang_pop_uinteger(dest)
#define SLANG_SHORT_TYPE_pop(dest,aux)	  SLang_pop_short(dest)
#define SLANG_USHORT_TYPE_pop(dest,aux)	  SLang_pop_ushort(dest)
#define SLANG_LONG_TYPE_pop(dest,aux)	  SLang_pop_long(dest)
#define SLANG_ULONG_TYPE_pop(dest,aux)	  SLang_pop_ulong(dest)
#define SLANG_FLOAT_TYPE_pop(dest,aux)	  SLang_pop_float(dest)
#define SLANG_DOUBLE_TYPE_pop(dest,aux)	  SLang_pop_double(dest, NULL, NULL)
#define SLANG_STRING_TYPE_pop(dest,aux)	  SLang_pop_slstring(dest)
#define SLANG_REF_TYPE_pop(dest,type)	  SLang_pop_ref(dest)
#define SLANG_OPAQUE_TYPE_pop(dest,type)  --FAIL--
#define SLANG_ARRAY_TYPE_pop(dest,type)   --FAIL--
#define SLANG_STRUCT_TYPE_pop(dest,type)  --FAIL--

#define I		SLANG_INT_TYPE
#define UI		SLANG_UINT_TYPE
#define UL		SLANG_ULONG_TYPE
#define UC		SLANG_UCHAR_TYPE
#define S		SLANG_STRING_TYPE
#define F 		SLANG_FLOAT_TYPE
#define D 		SLANG_DOUBLE_TYPE
#define R		SLANG_REF_TYPE
#define V		SLANG_VOID_TYPE
#define O		GTKOPAQUE_PLACEHOLDER

#define SAFE_DEREF_OPAQUE(po)	(po == NULL ? NULL : po->instance)
#define SAFE_DEREF_ARRAY(pa)	(pa == NULL ? NULL : pa->data)

